#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <armadillo>
#include <iomanip>
#include <vector>

using namespace std;
using namespace arma;

#include "optflow_feat_def.hpp"
#include "optflow_feat_impl.hpp"



uword ro = 120;
uword co = 160;
//Optical Flow features
//Knn classifier: N=3

//NICTA
const std::string path = "/home/johanna/codes/multi-actions/kth_testing/"; 


//Home
//const std::string path = "/home/johanna/codes-svn/multi-action/kth_testing/";

//UQ-server
//const std::string path = "/home/users/uqjcarva/Johanna/codes-linux/multi-actions/kth_testing/"; 



//wanda
//const std::string path = "/data2/Users/johanna/codes-wanda/kth_testing/";



////When I need to save
const std::string  feat_path ="./flow_features/"; //Create this folder


///OJO!!!!!!!!!!!!!!
const std::string  actionNames = "actionNames.txt";



int
main(int argc, char** argv)
{
  
  
  
  /*
   *  vec Ncents;
   *  Ncents << 16 << 32 << endr;
   *  
   *  for (uword n=0; n<Ncents.n_elem; ++n)
   *  {
   *  int N_cent = Ncents(n);
   *  opt_feat kth_optflow(path, actionNames, feat_path, co, ro, N_cent);
   *  kth_optflow.clustering_per_action(); 
   *  
   }
   */
  
 
  int N_cent = 16;
  int L_segm = 25;
  opt_feat kth_optflow(path, actionNames, feat_path, co, ro, N_cent, L_segm);
  
  
  /*
  //Linear Kernel:
  std::string model_name = "multi_svm_model_linear";
  //std::string model_name = "AUTOTRAIN_multi_svm_model_linear";
  //kth_optflow.training_svm(model_name, "LINEAR", 0);   // last parameter is gamma. Don't need for Linear Kernel
  //kth_optflow.testing_training (model_name);
  //kth_optflow.testing_svm(model_name);
  
  ///using majority rule
  kth_optflow.testing_svm_major_rule(model_name);
  

  */
  
  
  
  //sigma_set <<0.01 << 0.03 << 0.1 << 0.3 << 1 <<  3 << 10 << 30;
  //
  
  
     
     rowvec sigma_set; 
     sigma_set <<0.01 <<  0.1 << 0.3 << 1 << 3 << 10 << 30;
     
     for (uword gm=0; gm<sigma_set.n_elem; ++gm)
     {
       
       float gamma = 1/( 2*pow( sigma_set(gm),2 ) );
     //cout << "Training with 15 features: " << endl;
     //
     
       std::stringstream model_name;
       model_name << "multi_svm_modelRBF_sigma_" << sigma_set (gm);
       cout << model_name.str() << endl;
       //kth_optflow.training_svm(model_name.str(), "RBF", gamma);  
       //kth_optflow.testing_training (model_name.str());
       //kth_optflow.testing_svm( model_name.str() );
       ///using majority rule
       kth_optflow.testing_svm_major_rule( model_name.str() );
       getchar();
     
   }
  
  

  
  
}









/*
 * c **** *ma*ke_minimum_required(VERSION 2.8)
 * project( grassmann_clustering)
 * find_package( OpenCV REQUIRED)
 * find_package( Armadillo REQUIRED)
 * add_executable( run_3actions.exe Three_actions_UCF11.cpp)
 * target_link_libraries( run_3actions.exe ${OpenCV_LIBS} -O1 -larmadillo)
 */
